<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>01-props基础使用</title>
  </head>
  <body>
    <div id="app1"></div>
    <div id="app2"></div>
    <div id="app3"></div>

    <!-- 导入 react 主库 -->
    <script src="../js/react.development.js"></script>
    <!-- 导入 reactDom 扩展库 -->
    <script src="../js/react-dom.development.js"></script>
    <!-- 导入 babel 用于将jsx转为js -->
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
      // 定义类组件
      class Person extends React.Component {
        render() {
          console.log(this);
          const {name, age, sex} = this.props
          return (
            <ul>
              <li>名字：{name}</li>
              <li>年龄：{age}</li>
              <li>性别：{sex}</li>
            </ul>
          );
        }
      }
      // 渲染虚拟DOM
      const p = {name: 'st', age: 18, sex: '男'}
      // ReactDOM.render(<Person name="涛" age="18" sex="男"/>, document.getElementById("app1"));
      // ReactDOM.render(<Person name="米" age="28" sex="男"/>, document.getElementById("app2"));
      // 可以使用展开预算符传递参数
      ReactDOM.render(<Person {...p}/>, document.getElementById("app3"));
    </script>
  </body>
</html>
